package org.advanced.io;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

/**
 * @author John.zhang
 * @version Id: Memory, v 1.0 2020/12/14 14:01 ZhiYong Exp $
 * 基于内存流
 */
public class Memory {

    static String str = "Hello World";

    public static void main(String[] args) {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes());
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        int i = 0;
        while ((i = byteArrayInputStream.read()) != -1) {
            char c = (char) i;
            byteArrayOutputStream.write(Character.toUpperCase(c));
        }
        System.out.println(byteArrayOutputStream.toString());
    }

}
